package com.whsxt.utils;

import com.whsxt.domain.User;
import com.whsxt.realm.ActiveUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

public class CurrentLoginUtil {

    /**
     * 获取当前登录的用户
     * @return
     */
    public static User getUser(){

        Subject subject = SecurityUtils.getSubject();
        ActiveUser activeUser = (ActiveUser) subject.getPrincipal();
        return activeUser.getUser();
    }

    /**
     * 获取当前登录用户的id
     * @return
     */
    public static Integer getLoginUserId() {
        return getUser().getId();
    }
}
